﻿namespace RialternativeSample.Tests.Client.Mocks
{
    using System;
    using System.Collections.ObjectModel;
    using RialternativeSample.Client.Northwind.Interfaces;
    using RialternativeSample.Server.NorthwindService;

    public class CustomersDataServiceMock : ICustomersDataService
    {
        private ObservableCollection<Customers> customerStore;

        public CustomersDataServiceMock()
        {
            this.customerStore = new ObservableCollection<Customers>
            {
                new Customers
                {
                    CustomerID = "CUSTEST01"
                }
            };
        }

        public bool CanDeleteCustomers
        {
            get
            {
                return true;
            }
        }

        public bool CanEditCustomers
        {
            get
            {
                return true;
            }
        }

        public void GetCustomersAsync(Action<ObservableCollection<Customers>> callback)
        {
            callback(this.customerStore);
        }

        public void DeleteCustomer(Customers customer)
        {
            if (this.customerStore.Contains(customer))
            {
                this.customerStore.Remove(customer);
            }
        }

        public void PersistChangesAsync(Action callback)
        {
            if (callback != null)
            {
                callback();
            }
        }
    }
}
